<template>
  <dv-border-box-10
    :style="{ '--right': right + 'px' }"
    backgroundColor="#00003bc1"
    :color="['#4789e3', '#65bfe5']"
    class="right-row-bg"
  >
    <div class="right-row-box">
      <!-- <dv-border-box-12 class="border-box">dv-border-box-13</dv-border-box-12> -->
      <!-- <div class="tolbar">
                <h4 style="text-align: center; margin: 0; font-size: 20px;">实时数据</h4>
            </div> -->
      <div class="content">
        <div class="tools">
          <dv-decoration-7 :dur="2" class="title"
            >&nbsp;<font size="5">图源</font>&nbsp;</dv-decoration-7
          >
          <div class="tool">
            <i class="el-icon-close" @click="removeFn"></i>
          </div>
        </div>
        <div class="box-content">
          <h3 class="title">天地图</h3>

          <div class="card">
            <div class="card-item">
              <img src="../../assets/map_logo/t_map_1_s.png" class="image" />
              <p>
                深色图层&nbsp;&nbsp;<el-radio
                  v-model="radio"
                  @input="changeFn"
                  label="1"
                  ><span></span
                ></el-radio>
              </p>
            </div>
            <div class="card-item">
              <img src="../../assets/map_logo/t_map_1.png" class="image" />
              <p>
                矢量底图&nbsp;&nbsp;<el-radio
                  v-model="radio"
                  @input="changeFn"
                  label="2"
                  ><span></span
                ></el-radio>
              </p>
            </div>
            <div class="card-item">
              <img src="../../assets/map_logo/t_map_2.png" class="image" />
              <p>
                影像底图&nbsp;&nbsp;<el-radio
                  v-model="radio"
                  @input="changeFn"
                  label="3"
                  ><span></span
                ></el-radio>
              </p>
            </div>
            <div class="card-item">
              <img src="../../assets/map_logo/t_map_3.png" class="image" />
              <p>
                地形晕渲&nbsp;&nbsp;<el-radio
                  v-model="radio"
                  @input="changeFn"
                  label="4"
                  ><span></span
                ></el-radio>
              </p>
            </div>
          </div>
          <h3 class="title">高德地图</h3>

          <div class="card">
            <div class="card-item">
              <img src="../../assets/map_logo/g_map_1.png" class="image" />
              <p>
                矢量图层&nbsp;&nbsp;<el-radio
                  v-model="radio"
                  @input="changeFn"
                  label="5"
                  ><span></span
                ></el-radio>
              </p>
            </div>
            <div class="card-item">
              <img src="../../assets/map_logo/g_map_1_s.png" class="image" />
              <p>
                深色图层&nbsp;&nbsp;<el-radio
                  v-model="radio"
                  @input="changeFn"
                  label="6"
                  ><span></span
                ></el-radio>
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </dv-border-box-10>
</template>

<script>
import VectorLayer from "ol/layer/Vector";
import {
  GMapLayer_1,
  GMapLayer_1_s,
  TMapLayer_1,
  TMapLayer_1_s,
  TMapLayer_2,
  TMapLayer_3,
  TMapLayer_4,
  TMapTitle_1,
  TMapTitle_1_s,
  UMapVector_1,
} from "@/utils/orignLayres";
export default {
  name: "Test1LeftRow",
  data() {
    return {
      right: -500,
      flag: "M1",
      radio: "1",
      openMap: Map,
    };
  },
  props: {
    Map: {
      type: Object,
      requered: true,
    },
  },
  mounted() {},
  computed: {
    getMenuFlag() {
      return this.$store.state.activeMenu;
    },

  },
  watch: {
    getMenuFlag: {
      handler(newValue, oldValue) {
        
        this.right = -500;
        if (newValue === this.flag) {
          this.right = 0;
        }
      },
      deep: true,
      immediate: true,
    },

  },
  methods: {
    removeFn() {
      console.log("removeFn");
      this.right = -500;
    },
    changeFn(p) {
      // 获取所有图层
      let layers = this.Map.getLayers().getArray();
      

      for (let i = 0; i < layers.length; i++) {
        const layer = layers[i];
        // if (layer instanceof VectorLayer) {
        //   continue;
        // }
        if (!layer.get("isRemove")) {
          continue; 
        }
        layer.getSource().clear();
        this.Map.removeLayer(layer);
      }
      // this.Map.removeLayer(layers[0]);
      setTimeout(() => {
        //// 为了保险起见再次移除最后一个
        layers[0] instanceof VectorLayer ? "" : this.Map.removeLayer(layers[0]);

        switch (p) {
          case "1":
            this.Map.addLayer(TMapLayer_1_s);
            this.Map.addLayer(TMapTitle_1_s);
            break;
          case "2":
            this.Map.addLayer(TMapLayer_1);
            this.Map.addLayer(TMapTitle_1);
            break;
          case "3":
            this.Map.addLayer(TMapLayer_2);
            this.Map.addLayer(TMapTitle_1);
            break;
          case "4":
            this.Map.addLayer(TMapLayer_3);
            this.Map.addLayer(TMapTitle_1);
            break;
          case "5":
            this.Map.addLayer(GMapLayer_1);
            break;
          case "6":
            this.Map.addLayer(GMapLayer_1_s);
            break;
        }
      }, 250);

      // this.Map.addLayer(TMapTitle_1);
      // console.log(layers);
    },
    getAreaLayer() {
      // let geoJson = new VectorLayer({
      //   name: "geoJson",
      //   className: "geoJsonLine",
      //   source: new VectorSource({
      //     url: "./geoJson/China_line_.json",
      //     format: new GeoJSON(),
      //   }),
      //   style: new Style({
      //     stroke: new Stroke({
      //       color: [71, 137, 227, 1],
      //       width: 4, // 设置描边宽度为 4 像素
      //     }),
      //   }),
      // });
      // return geoJson;
    },
  },
};
</script>

<style lang="less" scoped>
.right-row-bg {
  position: absolute;
  top: 0;
  right: var(--right);
  bottom: 0;
  width: 20%;
  margin: 5px;
  z-index: 9;
  backdrop-filter: saturate(150%) blur(8px);
  -webkit-backdrop-filter: saturate(150%) blur(8px);
  animation: run 1s linear;

  color: #1dc1f5;
}

@keyframes run {
  0% {
    left: -100%;
  }

  100% {
    left: 0;
  }
}

.right-row-box {
  position: absolute;

  top: 0;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  // color: #4789e3;
  // color: #3f96a5;

  .border-box {
    width: 95%;
    height: 150px;
  }

  // .tolbar {
  //     width: 100%;
  //     height: 5%;
  // }

  .content {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    width: 100%;
    height: 100%;
  }
  .box-content {
    .title {
      text-align: left;
      margin: 10px;
      padding-left: 5px;
      border-left: 5px #139fc0 solid;
    }
    .card {
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: space-evenly;

      .card-item {
        width: 43%;
        height: 150px;
        border-radius: 8px;
        margin-bottom: 10px;
        background-color: #2f338a;
        transition: 0.3s linear;

        &:hover {
          scale: 1.05;
        }
        .image {
          width: 100%;
          height: 75%;
          border-radius: 8px;
        }
        p {
          margin: 0;
          text-align: center;
        }
      }
    }
  }
  .box-content:nth-child(1n) {
    flex: 2;
  }

  .box-content:nth-child(2n) {
    flex: 1;
  }
}

.tools {
  // display: flex;
  // flex-direction: row;
  // flex-wrap: nowrap;
  // justify-content: space-around;
  // align-items: center;
  position: relative;
  width: 100%;
  margin-bottom: 5px;

  .title {
    width: 100%;
    height: 30px;
  }

  .tool {
    position: absolute;
    right: 10px;
    top: 5px;
    background: #4687e240;
  }
}

.el-descriptions {
  background-color: transparent !important;
  color: #1dc1f5 !important;
  font-size: 18px;
}

.margin-left {
  margin-left: 10px;
}

// 图层选择的 radiobotton
.el-radio__input.is-checked .el-radio__inner {
  border-color: #ffc107 !important;
  background: #ffc107 !important;
}
</style>

